{extend name="Index/index"}

{block name="main"}

    <!--个个栏目体  开始-->
    <div class="right-wrapper">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this font20">通过审核的文章</li>
                <li class="font20">写文章</li>
            </ul>
            <div class="layui-tab-content">
                 <!--通过审核的文章-->
                <div class="layui-tab-item layui-show">
                    <div class="nav-show" style="display:block">
                        {if condition="$liste == null"}
                        <div style="display:block" class="no-like">
                            <img src="static/personal/img/collection.png" width="700">
                            <p>
                                暂无文章，赶紧去发表吧!
                            </p>
                        </div>
                        {else /}
                        <ul class="like-list" >
                            {volist name="liste" id="v"}
                            <li class="image">
                                <a href="" target="_blank" class="img-link">
                                    <img src="{$v['amage']}">
                                </a>
                                <div class="doc-items-wrapper">
                                    <div class="doc-items mt30" >
                                        <a href="" target="_blank">
                                            <h3>{$v['aname']}</h3>
                                        </a>
                                        <p>
                                            <span class="mtl50">1评</span>
                                            <span>{$v['regtime'] | date='y-m-d H:i:s',###}</span>

                                        </p>
                                    </div>
                                </div>
                            </li>
                            {/volist}
                        </ul>
                        {/if}
                    </div>
                </div>
                <!--写文章-->
                <div class="layui-tab-item">
                    <form class="layui-form" action="article/demo" method="post" enctype="multipart/form-data"
                          name="myform">
                        <div class="layui-form-item">
                            <label class="layui-form-label">一级分类</label>
                            <div class="layui-input-inline">
                                <select name="cid" lay-verify="required" lay-filter="onenav">
                                    <option value=""></option>
                                    {volist name="list" id="v"}
                                    <option value="{$v['cid']}">{$v['cname']}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">二级分类</label>
                            <div class="layui-input-inline">
                                <select name="cid" lay-verify="required" class="twonav">
                                    <option value=""></option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">文章标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="aname" lay-verify="title" placeholder="请输入文章标题" autocomplete="off"
                                       class="layui-input"><br>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">文章封面图</label>
                            <div class="layui-input-block">
                                <input type="file" name="mage">
                            </div>

                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">文章内容</label>
                            <div class="layui-input-block">
                    <textarea id="editor_id" name="content" style="width:700px;height:300px;">

                    </textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="fomDm">提交审核</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

    </div> <!--个个栏目体  结束-->
</div>  <!--main 结束-->
{js href="/static/home/js/jquery.min.js" /}
{js href="/static/home/js/bootstrap.js" /}
{js href="/static/personal/layui/layui.js"}
{js href="/static/personal/kindeditor/kindeditor-all.js"}
<script>
    layui.use(['form','element'], function () {
        // tab 选项卡
        var element = layui.element();
        //form 表单
        var form = layui.form();
        form.verify({
            title: function (value) {
                if (value.length < 4 || value.length > 20) {
                    return '只能输入4~20位';
                }
            }
        });
        //  分类选择
        form.on('select(onenav)', function (data) {
//            console.log(data.value); //得到被选中的值
            var id = data.value;
            $.ajax({
                type: 'get',
                url: 'article/' + id,
                dateType: 'json',
                success: function (data) {
//                    console.log(data);
                    $('.twonav').empty();
                    if (data !== null){
                        for (var i = 0; i < data.length; i++) {
                            $('<option value="' + data[i].cid + '">' + data[i].cname + '</option>').appendTo('.twonav');
                        }
                    }
                    form.render('select'); //刷新select选择框渲染
                },
                error: function () {
                    // AJAX执行失败
                    alert('ajax操作失败');
                }
            });
        });
    });
    KindEditor.ready(function(K) {
        window.editor = K.create('#editor_id', {
            allowImageUpload:true,
            uploadJson : '/personal/article/upload',
            afterUpload: function(){this.sync();},
            afterBlur : function() {
                    this.self.sync();
            },
            items : [
                'fontname','fontsize', '|','forecolor', 'hilitecolor','bold', 'italic','underline',
                'removeformat','|', 'justifyleft','justifycenter', 'justifyright','insertorderedlist',
                'insertunorderedlist','|', 'emoticons','link','media','|','image']
        });
    });

</script>

{/block}